package com.gome.wechat.program.dao;

import java.util.List;

import com.gome.wechat.program.entity.User;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import com.gome.wechat.program.entity.GroupActivityUser;

/**
 * Created by liwei113 on 2017/11/2 0002.
 */
public interface GroupActivityUserRepo extends JpaRepository<GroupActivityUser, Long> {
	
	@Query(value = "select gau from GroupActivityUser gau where gau.userId = :userId")
	List<GroupActivityUser> getListByUserId(@Param("userId") Long userId);

	@Query(value = "select u.id from group_activity_user as gau\n" +
			"left join `user` as u \n" +
			"on gau.user_id = u.id\n" +
			"where  gau.group_activity_id = :groupActivityId",nativeQuery = true)
	List<Long>  findJoinUserPhotos(@Param("groupActivityId") Long groupActivityId);


	List<GroupActivityUser> findByGroupActivityId(Long groupActivityId);

	Long countByGroupActivityId(Long groupActivityId);

	GroupActivityUser findByGroupActivityIdAndUserId(Long groupActivityId,Long userId);

}
